import { s_getcommontableinfo, s_getProduceInfo, status2text } from "@/services/basis";
import { ProCard, ProColumns, ProTable } from "@ant-design/pro-components";
import { Button,Image } from "antd";
import { useState } from "react";

const App:React.FC=()=>{
   const [total,setTotal]=useState(0);
  interface DataType{
    // x_id,id,vouch_code,org_id,warehouse_id,intype_id,worker_id,isreplace,repworker_id,workcenter_id,workgroup_id,stockin_time,
    // source_taskcard_id,material_id,quantity,userdefine_name,
    // code,name,invstd,invstd2,pic,munit_name,
    // workcenter_name,workgroup_name,worker_name,repworker_name,org_name,taskcard_sno
    rid?:number,
    x_id?:number,id?:number,vouch_code?:string,org_id?:number,warehouse_id?:number,intype_id?:number,worker_id?:number,
    isreplace?:number,repworker_id?:number,workcenter_id?:number,workgroup_id?:number,stockin_time?:string,
    source_taskcard_id?:number,material_id?:number,quantity?:number,userdefine_name?:string,
    code?:string,name?:string,invstd?:string,invstd2?:string,pic?:string,munit_name?:string,
    workcenter_name?:string,workgroup_name?:string,worker_name?:string,repworker_name?:string,org_name?:string,taskcard_sno?:string
 };

 const columns:ProColumns<DataType>[]=[
  {dataIndex:'rid',hidden:true,search:false},
  {dataIndex:'pic',title:'图片',width:80,
  //   render:(text)=>{
  //       var pic=text=="-"||text==undefined?"":"/basis_api/file/get?filename="+text;
  //       return <Image src={pic} style={{width:50,height:50}} alt='无' />
  //       },
  //  },
   render:(text,record,index,k)=>{
                     var pic="/basis_api/file/get2?filename="+record.code;
                     return   <Image src={pic}  style={{width:50,height:50}} alt='无' />
       }},
   {dataIndex:'workcenter_name',title:'工作中心',width:100},
   {dataIndex:'workgroup_name',title:'工作组',width:100},
  {dataIndex:'worker_name',title:'员工姓名',width:100},
  // {dataIndex:'vouch_code',title:'生产单号'},
  // {dataIndex:'taskcard_sno',title:'工序卡号'},
  {dataIndex:'stockin_time',title:'日期',valueType:'date',width:100},
  {dataIndex:'code',title:'SKU编码',width:100},
  {dataIndex:'name',title:'名称',width:100},{dataIndex:'invstd',title:'包装规格',search:false},
  {dataIndex:'invstd2',title:'型号',search:false}, 
  {dataIndex:'munit_name',title:'单位',search:false},{dataIndex:'quantity',title:'产量',search:false},
   
 ];
   
  return <>
       <ProCard title='员工产量汇总报表' style={{height:'85vh',overflow:'auto'}}>
          <ProTable<DataType>
            columns={columns}
            search={{span:4}}
            options={false}
            rowKey='rid'
            // request={async ()=>{
            //   const x=await s_getcommontableinfo({x_id:1,cate:[],id:0,source:'v_produce_reporting_count'});
            //   return{
            //     data:x.data[0],
            //     success:true,
            //   }
            //   }}
              request={async (param)=>{
                    const x=await s_getProduceInfo({source:'v_produce_reporting_count',x_id:1,
                                  fdata:{id:0,param}});
                     setTotal(x.data[0][0].count);
                      return{
                            data:x.data[1],
                            success:true,
                          }
                       }}
              scroll={{y:'50vh'}}
                    pagination={{
                    showQuickJumper:true,
                    showSizeChanger:true,
                    defaultPageSize:10,
                    defaultCurrent:1,
                    total,
                  }}
            />

       </ProCard>
     </>
};

export default App;